// src/store/useRecordStore.ts
import type { FourQuadrant, Quadrant, QuadrantItem } from '@/api/record/type';
import { defineStore } from 'pinia';
import { ref } from 'vue';

export const useRecordStore = defineStore(
  'record',
  () => {
    const list = ref<FourQuadrant[]>([
      {
        title: '重要紧急',
        key: 'Q1',
        items: [
          {
            name: '重要紧急1这嘎就 的就是佛i hi的发就发送i iOS的返回i爱上',
            startTime: '2025-01-07 12:00:00',
            endTime: '2025-01-07 13:00:00',
            isDone: false,
            isRepeat: false
          },
          {
            name: '重要紧急2',
            startTime: '2025-01-07 11:00:00',
            endTime: '2025-01-07 12:00:00',
            isDone: false,
            isRepeat: false
          }
        ]
      },
      {
        title: '重要不紧急',
        key: 'Q2',
        items: [
          {
            name: '重要不紧急你好',
            startTime: '2025-01-07 12:00:00',
            endTime: '2025-01-07 13:00:00',
            isDone: false,
            isRepeat: false
          },
          {
            name: '重要不紧急吃饭',
            startTime: '2025-01-07 11:00:00',
            endTime: '2025-01-07 12:00:00',
            isDone: false,
            isRepeat: false
          }
        ]
      },
      {
        title: '重要不紧急',
        key: 'Q3',
        items: [
          {
            name: '重要不紧急你好',
            startTime: '2025-01-07 12:00:00',
            endTime: '2025-01-07 13:00:00',
            isDone: false,
            isRepeat: false
          },
          {
            name: '重要不紧急吃饭',
            startTime: '2025-01-07 11:00:00',
            endTime: '2025-01-07 12:00:00',
            isDone: false,
            isRepeat: false
          }
        ]
      },
      {
        title: '不重要不紧急',
        key: 'Q4',
        items: [
          {
            name: '重要不紧急你好',
            startTime: '2025-01-07 12:00:00',
            endTime: '2025-01-07 13:00:00',
            isDone: false,
            isRepeat: false
          },
          {
            name: '重要不紧急吃饭',
            startTime: '2025-01-07 11:00:00',
            endTime: '2025-01-07 12:00:00',
            isDone: false,
            isRepeat: false
          }
        ]
      }
    ]);

    const setList = (priority: Quadrant, item: QuadrantItem) => {
      list.value.map((record) => {
        if (record.key === priority) {
          record.items.push(item);
        }
      });
      // list.value = [];
    };

    return {
      list,
      setList
    };
  },
  {
    persist: true
  }
);
